<!DOCTYPE html>
<html lang='zh-CN'>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>系统维护</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/materialdesignicons.min.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.min.css" rel="stylesheet">
<link href="js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid p-t-15">

  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-header">

          <div id="toolbar" class="toolbar-btn-action">
              <form class="form-inline" method="post" id="searchForm">
                <div class="form-group">
                  <label>标题名称:</label>
                  <input type="text" class="form-control" name="title">
                </div>
                <div class="form-group">
                  <button class="btn btn-info btn_query btn-round" type="button" id="searchFormBtn">查询</button>
                </div>
                <div class="form-group">
                  <button class="btn btn-success btn_query btn-round" type="button" onclick="changeStatus(1)">运行</button>
                </div>
                <div class="form-group">
                  <button class="btn btn-danger btn_query btn-round" type="button" onclick="changeStatus(0)">维护</button>
                </div>
              </form>
          </div>

        </div>
        <div class="card-body">

          <table id="grid_data"></table>

        </div>
      </div>
    </div>
  </div>

  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/bootstrap.min.js"></script>
  <script type="text/javascript" src="js/bootstrap-table/bootstrap-table.js"></script>
  <script type="text/javascript" src="js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
  <script type="text/javascript" src="js/zero2one/zero2one.version.js"></script>
  <script type="text/javascript" src="js/zero2one/zero2one.core.js"></script>
  <!-- bootstrap弹出框插件 -->
  <script type="text/javascript" src="js/jquery.bootstrap.min.js"></script>
  <script type="text/javascript">

      //设置表头
      var columns = [
          {checkbox: true},
          {field: 'id',title: 'ID'},
          {field: 'title',title: '标题名称'},
          {field: 'status_id',title: '运行状态'},
          {field: 'status_code',title: '状态码'}
      ];

      //进入主界面加载数据
      zero2one.datagrid("grid_data", "/upgradePage?f="+zero2one.r(),function (params) {
          return $.extend(zero2one.tableInitParam(params), zero2one.form2json("searchForm"));
      }, columns);


      function changeStatus(status) {
          //获取选中行的数据
          var datas = $('#grid_data').bootstrapTable('getSelections');
          //判断是否选中行数据，如果没有则提示
          if(datas.length == 1){
              $.messager.confirm("温馨提示", "您确定要更改系统运行状态吗?", function () {
                  //发送请求,执行批量删除
                  zero2one.request("/upgradeChangeStatus?f="+zero2one.r(), {"status" : status,"id" : datas[0].id, "statusCode" : status == 0 ? "STOP":"RUNTIME"},
                      function(data){
                         window.parent.location.reload();
                  });
              })
          }else{
              $.messager.alert("温馨提示", "请选择一条数据操作");

          }
      }

  </script>

</div>
</body>
</html>